<template>
	<view>	
		<view class="accont-card">
			<text class="accont-title">登录</text>
			<text class="accont-title-sm">欢迎回来，请输入账号密码</text>
			<view class="flex margin-top-lg">
				<view class="accont-text flex align-center">
					账号：
				</view>
				<view class="accont-input flex align-center ">
					<view class="margin-right-lg">
						<image src="../../static/images/accont/username.png" alt="" />
					</view>
					<input 
					 v-model="username"
					 type="text"
					 placeholder="请输入账号"
					/>
				</view>
			</view>
			<view class="flex margin-top-lg">
				<view class="accont-text flex align-center">
					密码：
				</view>
				<view class="accont-input flex align-center ">
					<view class="margin-right-lg">
						<image src="../../static/images/accont/password.png" alt="" />
					</view>
					<input 
					 v-model="password"
					 type="password"
					 placeholder="请输入密码"
					/>
				</view>
			</view>
		    <button class="accont-button" @click="handleLogin">登录</button>
			<view class="toRegister" @click="handleToRegister">
				还没有账号？去注册
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref,type Ref } from 'vue';
import { userStore } from '../../store/user'; 

//登录逻辑
const userstore=userStore()
const username:Ref<string>=ref('')
const password:Ref<string>=ref('')
const handleLogin =async () =>{
	userstore.login({username:username.value,password:password.value})
}
const handleToRegister=()=>{
	uni.navigateTo({
		url:"/pages/accont/register"
	})
}
</script>

<style lang="scss">
page{
	background-color:#FFF9F0 ;
} 
.accont-card{
	width: 600upx;
	height: 800upx;
	position: absolute;
	top:200upx;
	left:75upx;
	display: flex;
	flex-direction: column;
	align-items: center; /* 子元素水平居中 */
	text-align: center; /* 文本居中 */
	.accont-title{
		font-size: 60rpx;
		margin-top:30upx;

		font-weight: bolder;
		color: #FD7753;
	}
	.accont-title-sm{
		color:#999;
		font-size: 30upx;
		font-weight: 500;
		margin-top: 30upx;
	}
	.accont-input{
		background-color: #fff;
		width: 500upx;
		height: 100upx;
		padding: 20upx;
		border: 1rpx solid #ccc;
		border-radius: 20rpx;
		.accont-icons{
			width: 30rpx;
		}
	}
	.accont-text{
		font-size: 30upx;
	}
	image{
		width: 40upx;
		height: 40upx;
	}
	button{
		background-color: #FD7753;
		color: #fff;
		width: 600rpx;
		border-radius: 15rpx;
		margin-top: 70upx;
	}
	.toRegister{
		margin-top: 50rpx;
		margin-left: 420rpx;
		color: #FFA07A;
		font-size: 20upx;
		border-bottom:1rpx solid #FFA07A ;
	}
}  
</style>

